#!/bin/bash
BATTERY_OLD_STATUS="0"
while true
do
  BATTERY_C_D=$(cat /sys/class/power_supply/BAT0/status | tr -d '\n')
  BATTERY_STATUS=$(cat /sys/class/power_supply/BAT0/capacity)
  if [[ $BATTERY_STATUS -le "20" ]] && [[ $BATTERY_STATUS -lt $BATTERY_OLD_STATUS ]] && [[ $BATTERY_C_D -eq "Discharging" ]];
  then
    notify-send -i /usr/share/icons/Papirus-Dark/32x32/devices/battery.svg "BAT0 LOW $BATTERY_STATUS%"
  fi
  BATTERY_OLD_STATUS=$BATTERY_STATUS
  sleep 30
done
